package com.superbytecode.cloud.web.datetime;

import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.List;

/**
 * All rights Reserved, Designed By www.super-master.com
 *
 * @ProjectName: beacon-cloud
 * @Package: com.superbytecode.cloud.web.configure
 * @ClassName: DatetimeConvertPrimary
 * @Description: [配置默认的消息转换器（转换 HTTP 请求和响应）]
 * <p> </p>
 * @Author: [Lance Ting]
 * @Date: 2024/10/22 10:25
 * @Version: V1.0
 * @Copyright: 2024 www.super-master.cn Inc. All rights reserved.
 * TODO: 注意,本文件Lance Ting所作,如果转载或使用请标明具体出处!
 **/
@Configuration
public class DatetimeConvertPrimary implements WebMvcConfigurer {
    private final MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter;

    public DatetimeConvertPrimary(MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter) {
        this.mappingJackson2HttpMessageConverter = mappingJackson2HttpMessageConverter;
    }

    @Override
    public void extendMessageConverters(List<HttpMessageConverter<?>> converters) {
        converters.remove(mappingJackson2HttpMessageConverter);
        converters.add(0, mappingJackson2HttpMessageConverter);
    }
}